import requests from '@/utils/request.js'

export function getCaptcha() {
	return requests({
		url: '/code',
		header: {
			isToken: false
		},
		method: 'get',
		timeout: 20000
	})
}

export function login(userCard, password) {
	return requests({
		url: '/auth/login',
		headers: {
			isToken: false
		},
		method: 'post',
		data: {
			userCard,
			password
		}
	})
}

export function logout() {
	return requests({
		url: '/auth/logout',
		method: 'delete'
	})
}

export function register(username, userCard, password, age, sex, code, uuid) {
	return requests({
		url: '/auth/register',
		headers: {
			isToken: false
		},
		method: 'post',
		data: {
			username,
			userCard,
			password,
			age,
			sex,
			code,
			uuid
		}
	})
}

export function getUserInfo() {
	return requests({
		url: '/platform/user/getUser',
		method: 'get'
	})
}

export function searchUserInfo(username, userCard) {
	return requests({
		url: '/platform/user/searchUser',
		method: 'post',
		headers: {
			isToken: false
		},
		data: {
			username,
			userCard
		}
	})
}

export function modifyPassword(userCard, password) {
	return requests({
		url: '/platform/user/modifyPassword',
		method: 'put',
		headers: {
			isToken: false
		},
		data: {
			userCard,
			password
		}
	})
}